﻿<html lang=en>
	<head>
		<meta charset=utf-8>
		<meta http-equiv=X-UA-Compatible content="IE=edge">
		<meta name=viewport content="width=device-width,initial-scale=1">		
		<title></title>		
		<link rel="stylesheet" href="style.css" />
	</head>
	<body>

		<h1>DC API Reference</h1>

		<label>Introduction</label>
		<p>This plugin is specialized to fetch screen pixels, you can use it to monitor pixel color changes
		occur at any screen position.</p>

		<label>Plugin object:</label>
		<p>
			<code>
				<i class="tab"></i>plugin = _G.plugins.DC <tag>-- get the plugin object</tag>
			</code>
		</p>

		<label class="subject">Plugin methods:</label>
		<ul>
			<li><a href="#RGBCombine">plugin.RGBCombine</a></li>
			<li><a href="#RGBSplit">plugin.RGBSplit</a></li>
			<li><a href="#GetPixel">plugin.GetPixel</a></li>
			<li><a href="#WaitForPixel">plugin.WaitForPixel</a></li>
			<li><a href="#CapturePixelBlock">plugin.CapturePixelBlock</a></li>
		</ul>
		<p></p>


		<a name="RGBCombine"></a>
		<label>plugin.RGBCombine</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.RGBCombine(r, g, b)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>r:</dfn> value of the red component (0-255)<br />
					<dfn>g:</dfn> value of the green component (0-255)<br />
					<dfn>b:</dfn> value of the blue component (0-255)<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns int value of a color combined with 3 components.
				</td>
			</tr>
			<tr>
				<td>Samples</td>
				<td>
					<code>local plugin = _G.plugins.DC</code>
					<code>local rgb = plugin.RGBCombine(0xff, 0x00, 0x80) <tag>-- 0xff0080</tag></code>
				</td>
			</tr>
		</table>

		<a name="RGBSplit"></a>
		<label>plugin.RGBSplit</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td>
					plugin.RGBSplit <i>(rgb)</i><br />
				</td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>rgb:</dfn> int value of a color to be slitted <br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>Returns values of r, g, b components (0-255)</td>
			</tr>
			<tr>
				<td>Samples</td>
				<td>
					<code>local plugin = _G.plugins.DC</code>
					<code>local r, g, b = plugin.RGBSplit(0xff0080) <tag>-- 0xff, 0x00, 0x80</tag></code>
				</td>
			</tr>
		</table>

		<a name="GetPixel"></a>
		<label>plugin.GetPixel</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.GetPixel(x, y)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>x:</dfn> screen coordinates X<br />
					<dfn>y:</dfn> screen coordinates Y<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns int color value of screen pixel located at screen coordinates (x,y), returns -1 if failed..
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Captures a screen pixel and returns its color value.</td>
			</tr>
		</table>

		<a name="WaitForPixel"></a>
		<label>plugin.WaitForPixel</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.WaitForPixel(x, y, rgb, timeout)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>x:</dfn> screen coordinates X<br />
					<dfn>y:</dfn> screen coordinates Y<br />
					<dfn>rgb:</dfn> the expected color value<br />
					<dfn>timeout:</dfn> the maximum waiting duration, in milliseconds<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns true if the pixel matches within timeout duration, false otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>Waits until the pixel matches rgb value, up to timeout milliseconds.</td>
			</tr>
		</table>

		<a name="CapturePixelBlock"></a>
		<label>plugin.CapturePixelBlock</label>
		<table class="table api-table">
			<tr>
				<td>Function</td>
				<td><code>plugin.CapturePixelBlock(left, top, width, height)</code></td>
			</tr>
			<tr>
				<td>Arguments</td>
				<td>
					<dfn>left, top:</dfn> left-top corner of the block to be captured<br />
					<dfn>width, height:</dfn> size of the block to be captured<br />
				</td>
			</tr>
			<tr>
				<td>Return values</td>
				<td>
					Returns an array of rgb value if success, nil otherwise.
				</td>
			</tr>
			<tr>
				<td>Remarks</td>
				<td>
					Captures a block of pixels from the screen, returns color values of captured pixels.
					<code>local plugin = _G.plugins.DC</code>

					<code><br /><tag>-- capture a 5*5 block of pixels from the top-left screen corner</tag></code>
					<code>local pixels = plugin.CapturePixelBlock(0, 0, 5, 5)</code>

					<code><br /><tag>-- display rgb for all captures pixels</tag></code>
					<code>local _, color</code>
					<code>for _, color in ipairs(pixels) do</code>
					<code><i class="tab"></i>local r, g, b = plugin.RGBSplit(color)</code>
					<code><i class="tab"></i>print(r, g, b)</code>
					<code>end</code>
				</td>
			</tr>
		</table>

	</body>
</html>